home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR02 / DCGAMES1.ZIP / NEWGAME.ZIP / MERCHANT.SCR < prev    next >
Text File  |  1993-04-01  |  5KB  |  171 lines

  1. !
  2. ! Default merchant script..
  3. !
  4. ! (c) DC Software, 1992
  5. !
  6. ! Pending Enhancements
  7. !
  8. ! - I need to create a voice file (.VFL) with voices for this script.
  9. !   Look at the 'voice()' entries to see what voices it would play if
  10. !   they were available.  These voices could even be placed in the
  11. !   system's voice file (DCSOUNDS.VFL) in which case the voice command
  12. !   should read 'voice( xxxx, 1000 )'.
  13. !
  14.  
  15. !------------------------------------------------------------------------!
  16. :@TALK ! Talk to the character !
  17. !------------------------------------------------------------------------!
  18.  
  19. ! First, say hello.. !
  20.   if NPC.V0 > 0 then
  21.     writeln( "Hello ", player.name, ". What brings you back?" );
  22.   else
  23.     writeln( "Welcome to ", npc.name, ". How may I help you?" );
  24.   endif;
  25.  
  26. ! Now, set some variables..
  27.   NPC.V0 = 1; ! From know on, remember we've been here
  28.   L1 = 0;     ! No items have been SOLD to the player
  29.   L2 = 0;     ! No items have been BOUGHT from the player
  30.  
  31. ! Then start a loop and show a menu..
  32. :LOOP
  33.   L3 = select( "Buy", "Sell", "Talk", "Bye" );
  34.   on L3 goto BUY, SELL, CHAT;
  35.  
  36. ! ESCape and BYE get's us out of here..
  37. :CSTOP
  38.   if L1 = 0 and L2 = 0 then
  39.     writeln( "Next time buy something!" );
  40.   else
  41.     writeln( "It's been a pleasure doing business with you!" );
  42.   endif;
  43.   STOP;
  44.  
  45. !
  46. ! Player want's to buy something from us..
  47. !
  48. :BUY
  49.   L3 = select$( NPC );
  50.   if L3 < 0 goto LOOP; ! Nothing.. !
  51.  
  52.   if NPC.BP.VALUE >= GROUP.GOLD then 
  53.     writeln( "You don't have enough money!");
  54.     voice( "Broke" );
  55.   else
  56.     if npc.bp.type = FOOD and npc.bp.class = NONE then
  57.       L10 = 255 - group.food; ! Max food we can carry !
  58.       if L10 < npc.bp.count then
  59.         L11 = npc.bp.count - L10;
  60.         writeln( "You have to carry ", L11, " in your backpack" );
  61.         inc( group.food, L10 );
  62.         copy( npc.bp, player, L11 ); ! Put L11 foods in the backpack !
  63.         if failure then
  64.           writeln( "The excess merchandize is placed on the floor" );
  65.           drop( npc.bp, - L11 ); ! Negative count means "drop a copy" !
  66.         endif;
  67.       else
  68.         inc( group.food, npc.bp.count );
  69.       endif;
  70.     else
  71.       copy( NPC.BP, PLAYER );
  72.       if failure then
  73.         ! Value of failure is # that DID get moved !
  74.         L11 = npc.bp.count - failure;
  75.         writeln( L11, " are placed on the floor." );
  76.         drop( npc.bp, - L11 ); ! Negative count means "drop a copy" !
  77.       endif;
  78.     endif;
  79.     dec ( GROUP.GOLD, NPC.BP.VALUE );
  80.     inc ( L1 );                     ! Sold 1 item to the PLAYER !
  81.     writeln( "SOLD: ", NPC.BP.COUNT, " ", NPC.BP.NAME, " for ", $NPC.BP.VALUE );
  82.     voice( "Sold" );
  83.   endif;
  84.   goto BUY;
  85.  
  86. !
  87. ! Player want's to sell something to us..
  88. !
  89. :SELL
  90.   L3 = select$2( PLAYER, matching ); ! Shows only thing's that I might want to buy  !
  91.   if L3 < 0 then
  92.     if L3 = -2 then   ! No items in the player's backpack !
  93.       if L2 > 0 then
  94.         writeln( "You have no more items to sell." );
  95.         voice( "NonLeft" );
  96.       else
  97.         writeln( "You have no items to sell." );
  98.         voice( "NoItems" );
  99.       endif;
  100.     endif;
  101.     if L3 = -3 then   ! No items of the type(s) I sell in the backpack !
  102.       if L2 > 0 then
  103.         writeln( "You have no more items that I would like to buy." );
  104.         voice( "NonLeft" );
  105.       else
  106.         writeln( "You have no items that I would like to buy." );
  107.         voice( "NoItems" );
  108.       endif;
  109.     endif;
  110.     goto LOOP;
  111.   endif;
  112.  
  113. ! Buy an item at half price (it's used) !
  114.   if player.bp.count > 1 then
  115.     L10 = getnum( "Sell how many?", 0, player.bp.count );
  116.   else
  117.     L10 = 1;
  118.   endif;
  119.   if L10 > 0 then
  120.     L4 = (PLAYER.BP.VALUE+1) / 2;   ! Price paid for the item.
  121.     if L10 > 1 then
  122.       writeln( "Here is ", $L4, " for each of your ", L10, " ", PLAYER.BP.NAME, "s" );
  123.     else
  124.       writeln( "Here is ", $L4, " for your ", PLAYER.BP.NAME );
  125.     endif;
  126.     voice( "Bought" );
  127.     inc( group.gold, L4*L10 );   ! Pay the price
  128.     if L10 < player.bp.count then
  129.       L11 = player.bp.count;
  130.       player.bp.count = L10;
  131.       copy( PLAYER.BP, NPC );      ! Copy This Many  !
  132.       player.bp.count = L11 - L10; ! Leave this many !
  133.     else
  134.       move( player.bp, npc );  ! Move all of them !
  135.     endif;
  136.     inc( L2 );               ! Bought 1 item from the player !
  137.   endif;
  138.  
  139.   goto SELL;
  140.  
  141. !
  142. ! Handle conversation..
  143. !
  144. :CHAT
  145.   writeln( "What would you like to talk about?" );
  146.  
  147. :CHAT1
  148.   L3 = getstr("Name","Buy","Sell","Credit","Job","Bye");
  149.   if L3 = -1 then 
  150.     writeln( "Ok." );
  151.     goto LOOP; ! Pressed ESCape !
  152.   endif;
  153.  
  154. ! First, see if the keyword typed is in the character's text block !
  155.   if dotext( S0 ) goto CHAT1;
  156.  
  157. ! It didn't, so try the predefined ones..
  158.   on L3 goto CNAME, BUY, SELL, CCREDIT, CJOB, CSTOP;
  159.  
  160. ! Nope, try a 'DEFAULT' line
  161.   if not dotext( "DEFAULT" ) then
  162.     writeln( "I don't know anything about that!" );
  163.   endif;
  164.   goto CHAT1;
  165.  
  166. :CNAME   writeln( "My name is ", NPC.name, "." ); GOTO CHAT1;
  167. :CCREDIT writeln( "No credit sales, sorry!"    ); GOTO CHAT1;
  168. :CJOB    writeln( "I {buy} and {sell} things!" ); GOTO CHAT1;
  169.  
  170. ! Feel free to expand on this list.. !
  171.